﻿//http://haacked.com/archive/2007/12/07/tdd-and-dependency-injection-with-asp.net-mvc.aspx


using System;
using System.Web.Mvc;
using System.Web.Routing;
using AndrewSiemer.KnowledgeExchange.Web.Controllers;
using StructureMap;

namespace AndrewSiemer.KnowledgeExchange.Web
{
    public class StructureMapControllerFactory : DefaultControllerFactory
    {
        protected override IController  GetControllerInstance(RequestContext requestContext, Type controllerType)
        {
            if(controllerType == null)
                return base.GetControllerInstance(requestContext, controllerType);
     
            return ObjectFactory.GetInstance(controllerType) as Controller;
        }
    }
}
